#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Predesys Server - User Interface - Main module
@version: 0.2.5
@license: GPL 3.0 (see "license" file)
@author: Jose A. Jimenez
@contact: jajimc@gmail.com"""

import sys
sys.dont_write_bytecode = True
import os
import usage
import usersui
import usergroupsui
import addressesui
import servicesui
import servicetypesui
import servicepermissionsui
import systemui

if __name__ == "__main__":
    try:
        argc = len(sys.argv)
        if argc >= 2:
            if sys.argv[1] == "usergroups":
                usergroupsui.manageArgs(argc, sys.argv)
            elif sys.argv[1] == "users":
                usersui.manageArgs(argc, sys.argv)
            elif sys.argv[1] == "addresses":
                addressesui.manageArgs(argc, sys.argv)
            elif sys.argv[1] == "servicetypes":
                servicetypesui.manageArgs(argc, sys.argv)
            elif sys.argv[1] == "services":
                servicesui.manageArgs(argc, sys.argv)
            elif sys.argv[1] == "serviceperms":
                servicepermissionsui.manageArgs(argc, sys.argv)
            elif sys.argv[1] == "system":
                systemui.manageArgs(argc, sys.argv)
            else:
                print usage.get_usage()
        else:
            print usage.get_usage()
    except Exception as exc:
        print "Error:", exc
